package com.excilys.capicsoubank.selenium.pages;

import static org.fest.assertions.Assertions.assertThat;

public class AccountPage extends AbstractPage {

	private int accountId = 1;
	private Integer month = null;
	private Integer year = null;

	public void setAccountId(int accountId) {
		this.accountId = accountId;
	}

	public void setMonth(Integer month) {
		this.month = month;
	}

	public void setYear(int year) {
		this.year = year;
	}

	@Override
	public String getUrl() {
		String monthUrl = "";
		String yearUrl = "";

		if (month != null)
			monthUrl = "/" + month;

		if (year != null)
			yearUrl = "/" + year;

		return BASE_URL + "/account/" + accountId + yearUrl + monthUrl;
	}

	@Override
	public void isAt() {
		assertThat(find(".navbar").find(".active")).hasSize(1);
		assertThat(find(".navbar").find(".active").find("a").first().getText())
				.isEqualTo("Accounts");

		assertThat(find(".pagination")).isNotEmpty();

		// assertThat(find(".btn")).hasSize(0);
	}
}
